package fourzerofour.guoshixu.day04;

import java.util.Vector;

public class Main {
    public static void main(String[] args) {
        Vehicle vehicle =new Vehicle(5);
        System.out.println("初始速度为："+vehicle.getSpeed());
        vehicle.speedUp(100);
        System.out.println("加速后的速度为：" + vehicle.getSpeed());
        vehicle.speedDown(10);
        System.out.println("减速后的速度为：" + vehicle.getSpeed());
        System.out.println("恢复初始速度。。。");
        vehicle.setSpeed(40);
        System.out.println("您当前速度为：" + vehicle.getSpeed());


        Vehicle vehicle1 = new Vehicle(30,"长安");
        Vehicle vehicle2 = new Vehicle(60);
        Vehicle vehicle3 = new Vehicle(120,"吉普");

        Vehicle[] vehicles = {vehicle,vehicle1,vehicle2,vehicle3};

        for(int i=0;i<vehicles.length;i++){
            if(vehicles[i].getSpeed()<=30){
                vehicles[i].setSpeed(0);
            }else if(vehicles[i].getSpeed()>100){
                vehicles[i].setSpeed(100);
            }

            if(vehicles[i].getType().equals("长安")){
                vehicles[i].speedUp(100);
            }
        }

        for(int i=0;i<vehicles.length;i++){
            System.out.println("第" + (i+1) + "辆车速度为：" + vehicles[i].getSpeed());
        }


    }
}
